home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 59 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  3.3 KB

  1. From: Dick Menninger <Dick.Menninger@daytonoh.attgis.com>
  2. Message-ID: <DLCosx.Hn1@falcon.daytonoh.attgis.com>
  3. X-Original-Date: Thu, 18 Jan 1996 00:17:21 GMT
  4. Path: in1.uu.net!bounce-back
  5. Date: 18 Jan 96 00:50:31 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: Re: Throwing an exception from within a si
  9. Reply-To: mennid <Dick.Menninger@daytonoh.attgis.com>
  10. Organization: AT&T Global Information Solutions
  11. X-Newsreader: DiscussIT 2.5.1.3 for MS Windows [AT&T Software Products Division]
  12. References: <4dgj4m$9la@engnews1.Eng.Sun.COM>
  13. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  14.     iQBFAgUBMP2ZZeEDnX0m9pzZAQFGXQF9G8gI6yvGHAvqM1DPYWmK/H6MxucmiDIl
  15.     H3nX0KeilP958O94p6clo1yj61edaY6w
  16.     =S8Lx
  17.  
  18. > ==========Steve Clamage, 1/16/96==========
  19.  
  20. > In article 22h@galaxy.ucr.edu, thp@cs.ucr.edu (Tom Payne) writes:
  21.  
  22. > >Implicit in a qestion of what the Standard says are the related
  23. > >questions of what it should say and why --- why shouldn't signal
  24. > >handlers be allowed to throw exceptions?  (The question seems both
  25. > >interesting and appropriate.)
  26.  
  27. > Exceptions are synchronous, and unwind the stack from the point of the 
  28. > throw to the point of the handler. When an asynchronous signal arrives,
  29. > what is the state of the stack? Answer: unknown. In particular, the
  30. > stack might not even be in a consistent state -- arguments half pushed
  31. > during function entry or half popped during exit.
  32.  
  33. Signal handlers are analogous to interrupt handlers at
  34. application level.  They form separate asynchronous
  35. processing that may communicate to the rest of the
  36. application but are really a separate thread.  How they
  37. communicate to the rest of the application is colored
  38. thoroughly by their nature.  The problem in thinking
  39. about exceptions in signal handlers seems to be that
  40. everybody is treating them as part of the thread they interrupt.
  41. That leads you down the path to oblivion.  They should
  42. be seen as a separate thread of execution.  An exception
  43. does not go back through the special save boundary.
  44. To do that would be like an exception in one thread
  45. continuing through another threads stack.  When you
  46. look at a signal handler as a threadlike thing that happens
  47. to preempt another thread, you start making sensible
  48. decisions that allow a signal handler to do that little
  49. more that is probably necessary.  Since exceptions
  50. are required at rather basic levels now, precluding
  51. them is very unrealistic.
  52.  
  53. > In C, a signal handler isn't allowed to do much of anything, precisely
  54. > because the program state can't be known and may be inconsistent. The
  55. > same is true in C++.
  56.  
  57. It is just like an interrupt handler in that it could
  58. deadlock with the code it preempts.  OSes deal with
  59. that and do quite meaty stuff in the interrupt handlers.
  60. I certainly hope you are NOT trying to preclude the
  61. use of exceptions in interrupt handlers.  That would
  62. be totally absurd.
  63.  
  64. > Allowing exceptions to be thrown from a signal handler would place a
  65. > noticeable penalty on all programs to provide locks on every function
  66. > entry and exit, even programs that didn't throw exceptions or use
  67. > signals.
  68.  
  69. I don't think so.  That does not follow at all.
  70. See the earlier comments.
  71.  
  72. Good Day
  73. Dick
  74. Dick.Menninger@DaytonOH.ATTGIS.COM
  75. ---
  76. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  77.   Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  78.   is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
  79.